//---------------------------------------------------------------------------

#ifndef MainH
#define MainH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.Dialogs.hpp>
#include <Vcl.ExtDlgs.hpp>
#include "LPComponent.h"
#include "MLDSPlayer.h"
#include "SLControlCollection.h"
#include "VCL.LPControl.h"
#include "VLCommonDisplay.h"
#include "VLDSImageDisplay.h"
#include "VLDSVideoPlayer.h"
#include "VLAVIPlayer.h"
#include "VLImageDisplay.h"
#include "MLASFPlayer.h"
#include "MLWMFBaseComponent.h"
#include "VLASFPlayer.h"
#include "SLCommonFilter.h"
#include "VLCommonFilter.h"
#include "VLCrop.h"
#include "VLApplyMask.h"
#include <Vcl.Imaging.GIFImg.hpp>
#include <Vcl.ComCtrls.hpp>
#include "LPDrawLayers.h"
#include "SLComponentCollection.h"
#include "VLBasicDrawLayers.h"
#include "VLDraw.h"
#include "VLWienerFilter.h"

// user includes
#include <Xml.XMLDoc.hpp>
#include "ILBasicClassifier.h"
#include "ILNeuralNetwork.h"
#include "VLColorsToReal.h"
#include "VLSinkFilter.h"
#include "ILTrainingData.h"
#include "SLBasicGenericReal.h"
#include "SLGenericReal.h"
#include "SLBasicGenericRealMatrix.h"
#include "SLGenericRealMatrix.h"
#include "SLMultiInput.h"
#include "SLPair.h"
#include "VLBasicGenericFilter.h"
#include "VLGenericFilter.h"
#include <Vcl.ExtCtrls.hpp>
#include "LPControlDrawLayers.h"
#include "SLScope.h"
#include "SLCommonGen.h"
#include "SLSignalGen.h"
#include "SLGenericRealGen.h"
#include <boost/smart_ptr.hpp>
#include "Block.h"
#include "NetworkHelper.h"

#include <dir.h>


//---------------------------------------------------------------------------
class TMainForm : public TForm
{
__published:	// Von der IDE verwaltete Komponenten
	TOpenDialog *OpenDialog1;
	TVLImageDisplay *VLImageDisplay1;
	TVLCrop *VLCrop1;
	TTabControl *TabControl1;
	TLabel *InfoLabel;
	TEdit *ConfigEdit;
	TButton *SelectConfigButton;
	TLabel *Label2;
	TLabel *StatusLabel;
	TProgressBar *ProgressBar1;
	TButton *StartButton;
	TButton *CancelButton;
	TVLDraw *VLDraw1;
	TVLDrawPictureLayer *VLDrawPictureLayer1;
	TILNeuralNetwork *ILNeuralNetwork1;
	TILNeuralNetworkBackpropTrain *ILNeuralNetworkBackpropTrain1;
	TOpenDialog *OpenDialog2;
	TVLGenericFilter *VLGenericFilter1;
	TEdit *NetworkEdit;
	TButton *SelectNetworkButton;
	TLabel *CurrentFrameTextLabel;
	TLabel *FrameLabel;
	TButton *SelectVideoButton;
	TEdit *VideoEdit;
	TOpenDialog *OpenDialog3;
	TPanel *Panel1;
	TEdit *tEdit;
	TEdit *lEdit;
	TEdit *wEdit;
	TEdit *hEdit;
	TLabel *Label3;
	TLabel *Label4;
	TLabel *Label5;
	TLabel *Label6;
	TButton *LogoButton;
	TSLScope *SLScope1;
	TSLGenericReal *SLGenericReal1;
	TSLGenericReal *SLGenericReal2;
	TVLImageDisplay *VLImageDisplay2;
	TComboBox *ComboBox1;
	TEdit *ReductionFactorEdit;
	void __fastcall SelectVideoButtonClick(TObject *Sender);
	void __fastcall TabControl1Change(TObject *Sender);
	void __fastcall SelectConfigButtonClick(TObject *Sender);
	void __fastcall StartButtonClick(TObject *Sender);
	void __fastcall CancelButtonClick(TObject *Sender);
	void __fastcall SelectNetworkButtonClick(TObject *Sender);
	void __fastcall VLGenericFilter1ProcessData(TObject *Sender, TVLCVideoBuffer InBuffer,
          TVLCVideoBuffer &OutBuffer, bool &SendOutputData);
	void __fastcall ILNeuralNetwork1Result(TObject *ASender, ISLRealBuffer *AFeatures,
          TILClassifierResult *AResult);
	void __fastcall ILNeuralNetworkBackpropTrain1Progress(TObject *Sender, __int64 StartSample,
          __int64 EndSample, __int64 CurrentSample);
	void __fastcall LogoButtonClick(TObject *Sender);

private:	// Anwender-Deklarationen
	float PREDICTING_THRESHOLD;

	Blocklist blocklist;
	bool progressCanceled;
	bool parameterTestTraining;
	std::vector<float> testResult;

	int frameReductionFactor;

	int activeTabIndex;

	int selectedNetworkType;
	UnicodeString networkTypes[10];

	NetworkHelper* networkHelper;

	TVLDSVideoPlayer* VLDSVideoPlayer1;

	void createPlayer();

public:		// Anwender-Deklarationen
	__fastcall TMainForm(TComponent* Owner);
	__fastcall ~TMainForm();
	void decodeConfigFile(UnicodeString fileName);
	void playVideo();
	void runParameterTest();
};
//---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif
